package com.eedi.framework.social.dal.mapper;

import com.eedi.framework.common.enums.UserTypeEnum;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.social.dal.dataobject.SysSocialUserBindDO;
import com.eedi.framework.social.enmus.SysSocialTypeEnum;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface SysSocialUserBindMapper extends BaseMapperX<SysSocialUserBindDO> {

    default void deleteByUserTypeAndUserIdAndSocialType(UserTypeEnum userType, String userId, SysSocialTypeEnum socialType) {
        delete(new LambdaQueryWrapperX<SysSocialUserBindDO>()
                .eq(SysSocialUserBindDO::getUserType, userType)
                .eq(SysSocialUserBindDO::getUserId, userId)
                .eq(SysSocialUserBindDO::getSysSocialType, socialType));
    }

    default void deleteByUserTypeAndSocialUserId(UserTypeEnum userType, String socialUserId) {
        delete(new LambdaQueryWrapperX<SysSocialUserBindDO>()
                .eq(SysSocialUserBindDO::getUserType, userType)
                .eq(SysSocialUserBindDO::getUserId, socialUserId));
    }

    default SysSocialUserBindDO selectByUserTypeAndSocialUserId(UserTypeEnum userType, String socialUserId) {
        return selectOne(SysSocialUserBindDO::getUserType, userType,
                SysSocialUserBindDO::getSysSocialUserId, socialUserId);
    }

    default List<SysSocialUserBindDO> selectListByUserIdAndUserType(String userId, UserTypeEnum userType) {
        return selectList(new LambdaQueryWrapperX<SysSocialUserBindDO>()
                .eq(SysSocialUserBindDO::getUserId, userId)
                .eq(SysSocialUserBindDO::getUserType, userType));
    }

}
